The ValueIterator object contains the following methods:
The Initialize method initializes a ValueIterator Object.
Initialize(VhsSiteService As String, TagString As String, TimeStampEarliest As Date, TimeStampLatest As Date,_ IncludeDeleted As Long) As Long
| Parameter | Required | Description |
|---|---|---|
|
VhsSiteService |
Yes |
The site and service name of the VHS point tag, in "site.service" format. |
|
TagString |
Yes |
The point tag from which data is being retrieved in valid CygNet tag string format. |
|
TimeStampEarliest |
Yes |
The starting date of the retrieval period. Enter 0 for the date of the earliest timestamp. |
|
TimeStampLatest |
Yes |
The ending date of the retrieval period. Enter 0 for the date of the latest timestamp. |
|
IncludeDeleted |
Yes |
Indicates whether to include deleted records (1) or not (0). |
Returns a value based on whether the initialization was successful or not (1 = Success; 0 = Failure). The cursor is placed at the first (earliest) value by default. Note that some timestamps outside the specified time period may be returned by the iterator if the value continues into the time period.
Example
The following subroutine demonstrates the use of the Initialize, MoveFirst, and GetForward methods of the ValueIterator Object. It displays all values (with timestamps) for a given point.
|
Sub DisplayAllValues (tagString) Dim vhsValueIter, histEntry lstValues.ResetContent
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", tagString, 0, 0, 0 vhsValueIter.MoveFirst
'Show all points in a list box While (vhsValueIter.GetForward(histEntry)) lstValues.AddString CStr(histEntry.TimeStamp) & " "_ & CStr(histEntry.Value) Wend End Sub |
The GetBackward method retrieves information about the previous value in the iteration list. Returns a HistoryEntryEx object in the pVal variable.
GetBackward(pVal As Variant) As Long
| Parameter | Required | Description |
|---|---|---|
|
pVal |
Yes |
Returns the timestamp, status, user status, and value for the value entry. Type: HistoryEntryEx |
The GetBackward function retrieves information for a value and moves the cursor backward to the previous value. The return value is 1 while there are still values in the list. When TimeStampEarliest (as specified during initialization) or the beginning of the list is reached, 0 is returned.
Example
The following subroutine demonstrates the use of the Initialize, MoveLast, and GetBackward methods of the ValueIterator Object. It displays up to numValues of the most recent values for the point, POINT1.
|
Sub DisplayLatestValues (numValues) Dim vhsValueIter, histEntry, counter lstValues.ResetContent counter = 0
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", "CYGDEMO.UIS:POINT1", 0, 0, 0 vhsValueIter.MoveLast
'Show all points in a list box While ((vhsValueIter.GetBackward(histEntry)) And (counter < numValues)) lstValues.AddString CStr(histEntry.TimeStamp) & " "_ & CStr(histEntry.Value) counter = counter + 1 Wend End Sub |
The GetBackwardEx method retrieves information about the previous value in the iteration list. Returns a ValueEntryEx object in the pVal variable.
GetBackwardEx(pVal As Variant) As Long
| Parameter | Required | Description |
|---|---|---|
|
pVal |
Yes |
Returns the timestamp, status, user status, value, time ordinal, and rollup information for the value entry. Type: ValueEntryEx |
The GetBackwardEx function retrieves information for a value and moves the cursor backward to the previous value. The return value is 1 while there are still values in the list. When TimeStampEarliest (as specified during initialization) or the beginning of the list is reached, 0 is returned.
Example
The following subroutine demonstrates the use of the Initialize, MoveLast, and GetBackwardEx methods of the ValueIterator Object. It displays up to numValues of the most recent values for the point, POINT1.
|
Sub DisplayLatestValues (numValues) Dim vhsValueIter, valueEntry, counter lstValues.ResetContent counter = 0
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set valueEntry = CreateObject("CxVhsLib.ValueEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", "CYGDEMO.UIS:POINT1", 0, 0, 0 vhsValueIter.MoveLast
'Show all points in a list box While ((vhsValueIter.GetBackwardEx(valueEntry)) And (counter < numValues)) lstValues.AddString CStr(valueEntry.TimeStamp) & " "_ & CStr(valueEntry.Value) counter = counter + 1 Wend End Sub |
The GetForward method retrieves information about the next value in the iteration list. Returns a HistoryEntryEx object in the pVal variable.
GetForward(pVal As Variant) As Long
| Parameter | Required | Description |
|---|---|---|
|
pVal |
Yes |
Returns the timestamp, status, user status, and value for the value entry. Type: HistoryEntryEx |
The GetForward function retrieves information for the next value and moves the cursor forward to the value. The return value is 1 while there are still values in the list. When TimeStampLatest (as specified during initialization) or the end of the list is reached, 0 is returned.
Example
The following subroutine demonstrates the use of the Initialize, MoveFirst, and GetForward methods of the ValueIterator Object. It displays all values (with timestamps) for a given point.
|
Sub DisplayAllValues (tagString) Dim vhsValueIter, histEntry lstValues.ResetContent
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", tagString, 0, 0, 0 vhsValueIter.MoveFirst
'Show all points in a list box While (vhsValueIter.GetForward(histEntry)) lstValues.AddString CStr(histEntry.TimeStamp) & " "_ & CStr(histEntry.Value) Wend End Sub |
The GetForwardEx method retrieves information about the next value in the iteration list. Returns a ValueEntryEx object in the pVal variable.
GetForwardEx(pVal As Variant) As Long
| Parameter | Required | Description |
|---|---|---|
|
pVal |
Yes |
Returns the timestamp, status, user status, value, time ordinal, and rollup information for the value entry. Type: ValueEntryEx |
The GetForwardEx function retrieves information for the next value and moves the cursor forward to the value. The return value is 1 while there are still values in the list. When TimeStampLatest (as specified during initialization) or the end of the list is reached, 0 is returned.
Example
The following subroutine demonstrates the use of the Initialize, MoveFirst, and GetForwardEx methods of the ValueIterator Object. It displays all values (with timestamps) for a given point.
|
Sub DisplayAllValues (tagString) Dim vhsValueIter, valueEntry lstValues.ResetContent
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set valueEntry = CreateObject("CxVhsLib.ValueEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", tagString, 0, 0, 0 vhsValueIter.MoveFirst
'Show all points in a list box While (vhsValueIter.GetForwardEx(valueEntry)) lstValues.AddString CStr(valueEntry.TimeStamp) & " "_ & CStr(valueEntry.Value) Wend End Sub |
The MoveFirst method moves to the first value in the iteration list.
MoveFirst() As Long
Returns a value based on whether the method was successful or not (1 = Success; 0 = Failure).
Example
The following subroutine demonstrates the use of the Initialize, MoveFirst, and GetForward methods of the ValueIterator Object. It displays all values (with timestamps) for a given point.
|
Sub DisplayAllValues (tagString) Dim vhsValueIter, histEntry lstValues.ResetContent
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", tagString, 0, 0, 0 vhsValueIter.MoveFirst
'Show all points in a list box While (vhsValueIter.GetForward(histEntry)) lstValues.AddString CStr(histEntry.TimeStamp) & " "_ & CStr(histEntry.Value) Wend End Sub |
The MoveLast method moves to the last value in the iteration list.
MoveLast() As Long
Returns a value based on whether the method was successful or not (1 = Success; 0 = Failure).
Example
The following subroutine demonstrates the use of the Initialize, MoveLast, and GetBackward methods of the ValueIterator Object. It displays up to numValues of the most recent values for the point, POINT1.
|
Sub DisplayLatestValues (numValues) Dim vhsValueIter, histEntry, counter lstValues.ResetContent counter = 0
Set vhsValueIter = CreateObject("CxVhsLib.ValueIterator") Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
'Initialize value iterator vhsValueIter.Initialize "CYGDEMO.VHS", "CYGDEMO.UIS:POINT1", 0, 0, 0 vhsValueIter.MoveLast
'Show all points in a list box While ((vhsValueIter.GetBackward(histEntry)) And (counter < numValues)) lstValues.AddString CStr(histEntry.TimeStamp) & " "_ & CStr(histEntry.Value) counter = counter + 1 Wend End Sub |